﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UtilZ.Dotnet.WindowsDesktopEx.Winform;
using System.Drawing;
using UtilZ.Dotnet.WindowsDesktopEx.Base;

namespace UtilZ.Dotnet.WindowsDesktopEx.Winform
{
    /// <summary>
    /// Winform异步执行对象创建工厂类
    /// </summary>
    public class PartAsynExcuteFactoryWinform : PartAsynExcuteFactoryAbs
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public PartAsynExcuteFactoryWinform()
            : base()
        {

        }

        /// <summary>
        /// 转换遮罩层背景色
        /// </summary>
        /// <param name="shadeBackground">遮罩层背景色对象</param>
        /// <returns>遮罩层背景色</returns>
        public static Color ConvertShadeBackground(object shadeBackground)
        {
            if (shadeBackground == null)
            {
                return System.Drawing.Color.White;
            }
            else
            {
                return (Color)shadeBackground;
            }
        }

        /// <summary>
        /// 创建异步执行对象
        /// </summary>
        /// <typeparam name="T">异步执行参数类型</typeparam>
        /// <typeparam name="TContainer">容器控件类型</typeparam>
        /// <typeparam name="TResult">异步执行返回值类型</typeparam>
        /// <returns>异步执行对象</returns>
        public override IAsynExcute<T, TContainer, TResult> CreateExcute<T, TContainer, TResult>()
        {
            return new WinformPartAsynExcute<T, TContainer, TResult>();
        }
    }
}
